/**
 *@Description 清单抽检反馈首页
 */
var billCtrl  = new XFApp.client();
XFApp.client.prototype.bill = {
	successCode : "10000",
	page : null,
	urlItems : {
		queryByPageURL : basePath+"/userCenter/bill/queryCheckPage"
	},
	queryPage : function(){
		_this = this;
		if(!!_this.page){
			_this.page.page("remote",0,$('#searchForm').serialize());
		}else{
		_this.page = $("#page").page({
			pageSize : 10,
			remote: {
				url: _this.urlItems.queryByPageURL,
		        params: $('#searchForm').serialize(), 
		        success: function (data, pageIndex) {
		        	if(data.code==_this.successCode){
		        		var pageResult = data.result;
		        		if(null == data 
								|| null == data.result 
									|| null == data.result.itemList
										|| data.result.itemList.length < 1){
		        			$("#page_grid").html('<tr><td align="center" colspan="11">暂无数据</td></tr>');
		        		}else{
		        			$("#page_grid").html($("#dataTmp").render(pageResult.itemList));
		        		}
		        	}else{
		        		window.webDialogUtil.alert("提示","操作失败");
		        	}
		        },
		        error : function(){
		        	window.webDialogUtil.alert("提示","操作失败");
		        }
			},
			firstBtnText : '首页',
			lastBtnText : '尾页',
			prevBtnText : '上一页',
			nextBtnText : '下一页',
			showInfo : true,
			showJump : true,
			jumpBtnText : '跳转',
			showPageSizes : true,
			infoFormat : '共{pageCount}页,{total}项'
		});
		}
	},
	dataFormat : function(timeLong){
		if(null == timeLong
				|| "" == timeLong){
			return "";
		}
		return new Date(timeLong*1000).format("yyyy-MM-dd hh:mm:ss")
	},
	event : function(){
		_this = this;
		
		$("#searchButton").on("click",function(){
			billCtrl.bill.queryPage();
		});
		
		billCtrl.bill.queryPage();
		
		$("#checkPartment_sel").bsSuggest({
			idField: "dictCode",  
			keyField: "dictName",
			effectiveFields :["dictCode","dictName"],
			effectiveFieldsAlias:{dictCode:"编码",dictName:"名称"},
	        data: {
	           'value':[{'dictCode':'1',dictName:'海关'},{'dictCode':'2',dictName:'检验检疫'}],
	        }
	   }).on('onSetSelectValue', function (e, keyword) {
		   $("#checkPartment").val(keyword.id);
	    })
	    .on('onUnsetSelectValue', function (e) {
	        $("#checkPartment").val("");
	    });
		$("#checkPartment_sel").on("blur",function(){
			if(!$(this).val()){
				 $("#checkPartment").val("");
			}
		});
	},
};
$.views.converters({
	ftime : function(value) {
		return billCtrl.bill.dataFormat(value) ;
	},
	fdkstatus : function(value){
		return dksCtrl.dockerstatus.get(value);
	}
});
$(function(){
	billCtrl.bill.event();
});